#include<bits/stdc++.h>
using namespace std;
int arr[2000001],n;
double x,y;
int main(){
    cin>>n;
    for(int i = 1;i<=n;i++){
        cin>>x>>y;
        for(double j = 1;j<=y;j++){
            if(arr[int(j*x)] == 0) arr[int(j*x)] = 1;//开灯
            else arr[int(j*x)] = 0;
        }
    }
    
    for(int i = 1;i<=2000001;i++){
        if(arr[i] == 1){
            cout<<i;
            break;
        }
           
    }
    

    return 0;
}